package com.huawei;

import org.junit.Test;

import java.util.Scanner;

/**
 * Created by Z-hong on 2024/7/2.
 */

public class HJ2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        str=str.toLowerCase();
        char n = scanner.next().charAt(0);
        n=Character.toLowerCase(n);

        System.out.println(getCount(str,n));
    }

    public static int getCount(String str,char n) {
        int count = 0;
        char[] arr=str.toCharArray();

        for(int i=0;i<arr.length;i++){
            if(arr[i] == n||arr[i] == (n+32)){
                count++;
            }
        }
        return  count;
    }
}
